﻿using System;
using System.Collections.Generic;
using System.Xml.Serialization;
using Infrastructure;

namespace SubsDownloader.Core.AppSettings
{
    public class FolderScanerSettings : SettingsBase
    {
        // Local Variable
        private TimeSpan m_TimeSinceLastEvent;

        // Public Property - XmlIgnore as it doesn't serialize anyway
        [XmlIgnore]
        public TimeSpan ReSearchSubtitlesInterval
        {
            get { return m_TimeSinceLastEvent; }
            set { m_TimeSinceLastEvent = value; }
        }

        // Pretend property for serialization
        [XmlElement( "TimeSinceLastEvent" )]
        public long TimeSinceLastEventTicks
        {
            get { return m_TimeSinceLastEvent.Ticks; }
            set { m_TimeSinceLastEvent = new TimeSpan( value ); }
        }

        private List<string> _mediaTypes;

        /// <summary>
        /// Suported media file types, such as .mkv, .avi, etc...
        /// </summary>
        public List<string> MediaTypes
        {
            get
            {
                return _mediaTypes;
            }
            set { _mediaTypes = value; }
        }

        /// <summary>
        /// The monitor interval in seconds
        /// </summary>
        public int MonitorInterval { get; set; }

        public bool LoadOnlyFilesWithoutSubtitles { get; set; }

        /// <summary>
        /// which folders the app should monitor
        /// </summary>
        public List<string> FolderToMonitor { get; set; }

        public List<string> IgnoredMedia { get; set; }

        public FolderScanerSettings ()
        {
            FolderToMonitor = new List<string>();
            IgnoredMedia = new List<string>();
            MediaTypes = new List<string>();
        }

        public override void SetDefaults ()
        {
            FolderToMonitor = new List<string>();
            IgnoredMedia = new List<string>();
            ReSearchSubtitlesInterval = new TimeSpan( 0, 3, 0, 0 );
            MonitorInterval = Convert.ToInt32( TimeSpan.FromMilliseconds( 3 ).TotalMilliseconds );
            MediaTypes = new List<string> { ".avi", ".mkv", ".m2ts" };
        }
    }
}
